﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gollie.Controls
{
	public partial class VendorPresenterFull : BaseUserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			this.SetVendor();
		}

		private void SetVendor()
		{
			VendorInfo vendor = VendorInfo.GetVendorInfo(Convert.ToUInt32(this.VendorId));

			if (vendor == null)
			{
				this.pnlHref.Visible = false;
				this.pnlNoHref.Visible = false;

				return;
			}

			bool isHref = string.IsNullOrEmpty(vendor.Website) == false;
			bool hasLogo = string.IsNullOrEmpty(vendor.LogoMediumPath) == false;

			this.SetNaw(vendor, isHref, hasLogo);
		}

		private void SetNaw(VendorInfo vendor, bool isHref, bool hasLogo)
		{
			this.pnlHref.Visible = isHref;
			this.pnlNoHref.Visible = !isHref;

			if (isHref)
			{
				this.ImageRenderer1.Visible = hasLogo;
				if (hasLogo)
					this.ImageRenderer1.ImagePath = vendor.LogoMediumPath;

				this.hplWebsite.NavigateUrl = vendor.Website;
				this.lblBedrijfsnaam1.Text = vendor.BedrijfsNaam;
				this.lblPlaats1.Text = vendor.Plaats;
				this.lblStraat1.Text = vendor.Straat;
			}
			else
			{
				this.ImageRenderer2.Visible = hasLogo;
				if (hasLogo)
					this.ImageRenderer2.ImagePath = vendor.LogoMediumPath;

				this.lblBedrijfsnaam2.Text = vendor.BedrijfsNaam;
				this.lblPlaats2.Text = vendor.Plaats;
				this.lblStraat2.Text = vendor.Straat;
			}
		}

		public uint VendorId
		{
			get;
			set;
		}

	}
}